home *** CD-ROM | disk | FTP | other *** search
- unit RPrinter;
-
- interface
-
- uses
- ExtCtrls,
- SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
- Forms, Dialogs, StdCtrls, Printers;
-
- { Status format characters }
- { %% - % character }
- { %p - Current Page }
- { %f - First Page }
- { %l - Last Page }
- { %d - Printer Device Name }
- { %r - Printer Driver Name }
- { %t - Printer Port }
- { %0 through %9 - Status Text Line }
-
- const
- NA = -32768; { n/a value }
- BOXLINEALL = 15;
- BOXLINEBOTTOM = 8;
- BOXLINEHORIZ = 12;
- BOXLINELEFT = 1;
- BOXLINENONE = 0;
- BOXLINERIGHT = 2;
- BOXLINETOP = 4;
- BOXLINEVERT = 3;
-
- type
- EReportPrinter = class(Exception);
-
- TPrintPageEvent = function( Sender: TObject;
- var PageNum: integer): boolean of object;
-
- TPrintJustify = (pjCenter,pjLeft,pjRight);
- TPrintUnits = (unInch,unMM,unUser);
- TLineHeightMethod = (lhmLinesPerInch,lhmFont);
- TBKMode = (bkTransparent,bkOpaque);
- TDestination = (destPrinter,destPreview,destFile);
-
- TReportPrinter = class(TComponent)
- protected
- { Property read/write methods }
- function GetCanvas: TCanvas;
- procedure SetStatusText(Value: TStrings);
- procedure SetLinesPerInch(NewLinesPerInch: integer);
- procedure SetLine(NewLine: integer);
- procedure SetColumn(NewColumn: integer);
- procedure SetLeftMargin(LeftWidth: double);
- function GetLeftMargin: double;
- procedure SetRightMargin(RightWidth: double);
- function GetRightMargin: double;
- procedure SetTopMargin(TopWidth: double);
- function GetTopMargin: double;
- procedure SetBottomMargin(BottomWidth: double);
- function GetBottomMargin: double;
- procedure SetTabShade(Shade: integer);
- function GetLeftWaste: double;
- function GetRightWaste: double;
- function GetTopWaste: double;
- function GetBottomWaste: double;
- function GetXPos: double;
- procedure SetXPos(NewXPos: double);
- function GetYPos: double;
- procedure SetYPos(NewYPos: double);
- procedure SetUnits(Units: TPrintUnits);
- procedure SetUnitsFactor(UnitsFactor: double);
- function GetPageHeight: double;
- function GetPageWidth: double;
- procedure SetBold(State: boolean);
- function GetBold: boolean;
- procedure SetUnderline(State: boolean);
- function GetUnderline: boolean;
- procedure SetItalic(State: boolean);
- function GetItalic: boolean;
- procedure SetStrikeout(State: boolean);
- function GetStrikeout: boolean;
- procedure SetOrientation(Value: TPrinterOrientation);
- procedure SetCopies(Value: integer);
- function GetCopies: integer;
- procedure SetPrinterIndex(Value: integer);
- function GetPrinterIndex: integer;
- function GetDeviceName: string;
- function GetDriverName: string;
- function GetPort: string;
- procedure SetDestination(Value: TDestination);
- procedure SetBKColor(Value: TColor);
- function GetBKColor: TColor;
-
- public
- { Public methods }
- constructor Create(AOwner: TComponent); override;
- destructor Destroy;
- procedure CheckPrinting;
- procedure CheckNotPrinting;
-
- procedure Execute;
- procedure NewPage;
- procedure Abort;
- procedure AbortPage;
- procedure UpdateStatus;
- procedure Reset;
- procedure ResetPrinter;
-
- { Positioning Methods }
- function X2D(Pos: double): integer;
- function Y2D(Pos: double): integer;
- procedure CR;
- procedure LF;
- procedure ResetLineHeight;
- procedure CRLF;
- procedure GotoHeader;
- procedure GotoFooter;
- procedure GotoXY(NewXPos: double;
- NewYPos: double);
- procedure Home;
- procedure SetColumns(NewColumns: integer;
- Between: double);
- procedure SetColumnWidth(Width: double;
- Between: double);
- procedure SetTopOfPage;
- function LinesLeft: integer;
- function ColumnLinesLeft: integer;
-
- { Printing Methods }
- procedure Print(Text: string);
- procedure PrintCenter(Text: string;
- Pos: double);
- procedure PrintFooter(Text: string;
- Justify: TPrintJustify);
- procedure PrintHeader(Text: string;
- Justify: TPrintJustify);
- procedure PrintLeft(Text: string;
- Pos: double);
- procedure PrintLn(Text: string);
- procedure PrintRight(Text: string;
- Pos: double);
-
- { Positioning Methods }
- function PopPos: boolean;
- function PushPos: boolean;
- function RestorePos(Index: byte): boolean;
- function SavePos(Index: byte): boolean;
-
- { Canvas Drawing Object Methods }
- procedure SetBrush(NewColor: TColor;
- NewStyle: TBrushStyle;
- NewBitmap: TBitmap);
- function CreateBrush(NewColor: TColor;
- NewStyle: TBrushStyle;
- NewBitmap: TBitmap): TBrush;
- procedure SetFont(NewName: string;
- NewSize: integer);
- function CreateFont(NewName: string;
- NewSize: integer): TFont;
- procedure SetPen(NewColor: TColor;
- NewStyle: TPenStyle;
- NewWidth: integer;
- NewMode: TPenMode);
- function CreatePen(NewColor: TColor;
- NewStyle: TPenStyle;
- NewWidth: integer;
- NewMode: TPenMode): TPen;
-
- { Tab Methods }
- procedure SetTab(NewPos: double;
- NewJustify: TPrintJustify;
- NewWidth: double;
- NewMargin: double;
- NewLines: byte;
- NewShade: byte);
- procedure ClearTabs;
- procedure ResetTabs;
- procedure Tab(LeftWidth: integer;
- RightWidth: integer;
- TopWidth: integer;
- BottomWidth: integer;
- ShadeOverride: integer);
-
- { GDI Wrapper Functions }
- function CreatePoint(X,Y: double): TPoint;
- function CreateRect(X1,Y1,X2,Y2: double): TRect;
- procedure Arc(X1,Y1,X2,Y2,X3,Y3,X4,Y4: double);
- procedure BrushCopy(const Dest: TRect;
- Bitmap: TBitmap;
- const Source: TRect;
- Color: TColor);
- procedure Chord(X1,Y1,X2,Y2,X3,Y3,X4,Y4: double);
- procedure CopyRect(const Dest: TRect;
- Canvas: TCanvas;
- const Source: TRect);
- procedure Draw(X,Y: double;
- Graphic: TGraphic);
- procedure DrawFocusRect(const Rect: TRect);
- procedure Ellipse(X1,Y1,X2,Y2: double);
- procedure FillRect(const Rect: TRect);
- procedure FloodFill(X,Y: double;
- Color: TColor;
- FillStyle: TFillStyle);
- procedure FrameRect(const Rect: TRect);
- procedure LineTo(X,Y: double);
- procedure MoveTo(X,Y: double);
- procedure Pie(X1,Y1,X2,Y2,X3,Y3,X4,Y4: double);
- procedure Polygon(const Points: array of TPoint);
- procedure Polyline(const Points: array of TPoint);
- procedure PrintBitmap(X,Y: double;
- ScaleX,ScaleY: double;
- Bitmap: TBitmap);
- procedure PrintBitmapRect(X1,Y1,X2,Y2: double;
- Bitmap: TBitmap);
- procedure Rectangle(X1,Y1,X2,Y2: double);
- procedure RoundRect(X1,Y1,X2,Y2,X3,Y3: double);
- procedure StretchDraw(const Rect: TRect;
- Graphic: TGraphic);
- procedure TextRect( Rect: TRect;
- X,Y: double;
- const Text: string);
-
- { Public properties }
- property Canvas: TCanvas;
- property CurrentPage: integer;
- property PageInvalid: boolean;
- property XDPI: integer;
- property YDPI: integer;
- property LineNum: integer;
- property ColumnNum: integer;
- property LeftWaste: double;
- property RightWaste: double;
- property TopWaste: double;
- property BottomWaste: double;
- property Columns: integer;
- property XPos: double;
- property YPos: double;
- property PageHeight: double;
- property PageWidth: double;
- property Bold: boolean;
- property Underline: boolean;
- property Italic: boolean;
- property Strikeout: boolean;
- property PrinterIndex: integer;
- property DeviceName: string;
- property DriverName: string;
- property Port: string;
- property Aborted: boolean;
- property Printing: boolean;
- property OriginX: double;
- property OriginY: double;
- property DevMode: PDevMode;
- property BKColor: TColor;
-
- published
-
- { Published properties }
- property FirstPage: integer;
- property LastPage: integer;
- property StatusLabel: TLabel;
- property StatusFormat: string;
- property StatusText: TStrings;
- property LineHeightMethod: TLineHeightMethod;
- property LinesPerInch: integer;
- property Units: TPrintUnits;
- property UnitsFactor: double;
- property MarginLeft: double;
- property MarginRight: double;
- property MarginTop: double;
- property MarginBottom: double;
- property TabShade: integer;
- property Title: string;
- property TextBKMode: TBKMode;
- property Destination: TDestination;
- property FileName: string;
- property PaintBox: TPaintBox;
- property Copies: integer;
- property Orientation: TPrinterOrientation;
-
- { Published events }
- property OnPrint: TNotifyEvent;
- property OnPrintPage: TPrintPageEvent;
- property OnBeforePrint: TNotifyEvent;
- property OnAfterPrint: TNotifyEvent;
- end;
-
- procedure Register;
-
- implementation
- end. { RPrinter }
-
-